#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000005;
vector<int> vc[MAXN]; int stt[MAXN], len[MAXN]; vector<int> tots;
namespace sa {
	int sa[MAXN], rk[MAXN], tmp[MAXN << 1], buc[MAXN], hei[MAXN];
	void sort_(int n, int m) {
		for (int i = 1; i <= m; i++) buc[i] = 0;
		for (int i = 0; i < n; i++) buc[rk[tmp[i]]]++;
		for (int i = 2; i <= m; i++) buc[i] += buc[i - 1];
		for (int i = n - 1; ~i; i--) sa[buc[rk[tmp[i]]]--] = tmp[i];
	}
	void init() {
		int n = tots.size(), m = 1000001; for (int i = 0; i < n; i++) rk[i] = tots[i] + 1, tmp[i] = i;
		sort_(n, m); for (int l = 1; ; l <<= 1) {
			int t = 0; for (int i = n - l; i < n; i++) tmp[t++] = i;
			for (int i = 1; i <= n; i++) if (sa[i] >= l) tmp[t++] = sa[i] - l;
			sort_(n, m); memcpy(tmp, rk, sizeof rk); rk[sa[1]] = m = 1;
			for (int i = 2; i <= n; i++) {
				rk[sa[i]] = tmp[sa[i]] == tmp[sa[i - 1]] && tmp[sa[i] + l] == tmp[sa[i - 1] + l] ? m : ++m;
			}
			if (m == n) break;
		}
	}
}
struct cmp {bool operator () (int x, int y) {return sa::rk[x] < sa::rk[y];}};
char ans[MAXN]; int n, m, q;
int read() {
	char ch; while ((ch = getchar()) <= ' '); int x = ch - '0';
	while ((ch = getchar()) > ' ') x = 10 * x + ch - '0';
	return x;
}
namespace sgt {
	pair<int, int> val[MAXN << 2]; int tag[MAXN << 2];
	void addtag(int rt, int w) {val[rt].first += w; tag[rt] += w;}
	void pushdown(int rt) {if (tag[rt]) addtag(rt << 1, tag[rt]), addtag(rt << 1 | 1, tag[rt]), tag[rt] = 0;}
	void pushup(int rt) {val[rt] = max(val[rt << 1], val[rt << 1 | 1]);}
	void build(int rt, int l, int r) {
		if (l == r) return val[rt] = {tots[sa::sa[l]] - 0x3f3f3f3f, l}, void();
		int mid = (l + r) >> 1; build(rt << 1, l, mid); build(rt << 1 | 1, mid + 1, r); pushup(rt);
	}
	void modify(int rt, int l, int r, int x, int y, int w) {
		if (x <= l && r <= y) return addtag(rt, w);
		int mid = (l + r) >> 1; pushdown(rt);
		if (x <= mid) modify(rt << 1, l, mid, x, y, w);
		if (y > mid) modify(rt << 1 | 1, mid + 1, r, x, y, w);
		pushup(rt);
	}
	int findfirst(int rt, int l, int r, int x) {
		if (val[rt].first < 0) return l - 1;
		if (l == r) return l;
		int mid = (l + r) >> 1, tmp; pushdown(rt);
		if (x > mid && (tmp = findfirst(rt << 1 | 1, mid + 1, r, x)) > mid) return tmp;
		return findfirst(rt << 1, l, mid, x);
	}
}
void disable(int u) {
	sgt::modify(1, 1, q, u, u, -0x3f3f3f3f); if (u > 1) sgt::modify(1, 1, q, 1, u - 1, -1);
}
void enable(int u) {
	sgt::modify(1, 1, q, u, u, 0x3f3f3f3f); if (u > 1) sgt::modify(1, 1, q, 1, u - 1, 1);
}
bool solve(int lim) {
	auto maxw = sgt::val[1];
	if (maxw.first < 0) return 1;
	if (maxw.first > lim) return 0;
	bool tag = lim > maxw.first;
	vector<int> prf; prf.push_back(0x3f3f3f3f);
	while (prf.back() != maxw.second) {
		prf.push_back(sgt::findfirst(1, 1, q, prf.back() - 1));
	}
	int u = prf.size() - 1;
	for (int i = 1; i <= u; i++) disable(prf[i]);
	if (tots[sa::sa[prf[u]] + 1]) enable(sa::rk[sa::sa[prf[u]] + 1]);
	if (solve(maxw.first - u)) {
		for (int i = maxw.first; i > maxw.first - u; i--) ans[i] = '1';
		if (tots[sa::sa[prf[u]] + 1]) disable(sa::rk[sa::sa[prf[u]] + 1]);
		for (int i = 1; i <= u; i++) enable(prf[i]);
		return 1;
	}
	if (tots[sa::sa[prf[u]] + 1]) disable(sa::rk[sa::sa[prf[u]] + 1]);
	if (tag == 0) {
		for (int i = 1; i <= u; i++) enable(prf[i]);
		return 0;
	}
	assert(solve(maxw.first - u + 1));
	for (int i = maxw.first + 1; i > maxw.first - u + 1; i--) ans[i] = '1';
	for (int i = 1; i <= u; i++) enable(prf[i]);
	return 1;
}
int main() {
	freopen("mcmf.in", "r", stdin);
	freopen("mcmf.out", "w", stdout);
	int ST = clock();
	n = read(); int m = 0, X = 0;
	for (int i = 1; i <= n; i++) {
		int k = read(); while (k--) {int x = read(); vc[i].push_back(x);}
		reverse(vc[i].begin(), vc[i].end()); m += vc[i].front(); X = max(X, vc[i].front());
		stt[i] = tots.size(); len[i] = vc[i].size();
		for (int j = 0; j < len[i]; j++) tots.push_back(vc[i][j]);
		tots.push_back(0);
	}
	fprintf(stderr, "N = %d, M = %d, X = %d\n", n, m, X);
	assert(n <= 1e6 && m <= 1e6);
	q = tots.size(); sa::init(); sgt::build(1, 1, q);
	for (int i = 1; i <= m + n; i++) ans[i] = '0';
	for (int i = 1; i <= n; i++) {
		if (tots[stt[i]]) enable(sa::rk[stt[i]]);
	}
	if (solve(m) == 0) puts("u jqh");
	else {
		for (int i = m, flg = 0; i; i--) {
			if (ans[i] == '1') flg = 1;
			if (flg) putchar(ans[i]);
		} puts("");
	}
	fprintf(stderr, "time %lf\n", 1.0 * (clock() - ST) / CLOCKS_PER_SEC);
}
